package com.spring.sunflower.conversation

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.makeramen.roundedimageview.RoundedImageView
import com.spring.sunflower.R
import com.spring.sunflower.bean.LatestVisitorBean
import com.spring.sunflower.util.DateTimeUtils
import java.util.*

/**
 * Created by Kevin on 2021/8/24<br/>
 *
 * Describe:<br/>
 */
class LatestVisitorAdapter(layoutResId: Int, data: MutableList<LatestVisitorBean.DatasBean>) :
    BaseQuickAdapter<LatestVisitorBean.DatasBean, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: LatestVisitorBean.DatasBean) {
        holder.setText(R.id.tvName, item.nickname)
        val ivAvatar: RoundedImageView = holder.getView(R.id.ivCover)
        Glide.with(context)
            .load(item.photo)
            .placeholder(R.drawable.ic_placeholder)
            .into(ivAvatar)
        val timeFormatText = DateTimeUtils.getTimeFormatText(Date((item.createTime).toLong()))
        holder.setText(R.id.tvLastMessage, "${timeFormatText}查看了你的资料")
    }
}